/**
 * mmio.h
 *
 * Defines the interface between memory operations and specific hardware
 * functionality.
 *
 * @author  Philippe Johnson
 */

#ifndef __MMIO_H__
#define __MMIO_H__

#include "common.h"

#define MMIOHASH( addr ) ( addr & 0x0FFF )

#define MMIO_BANKMIN 0x00           /* Smallest MMIO bank                   */
#define MMIO_BANKMAX 0x3F           /* Largest MMIO bank                    */
#define MMIO_MIN     0x2100         /* Smallest MMIO address                */
#define MMIO_MAX     0x437A         /* Largest MMIO address                 */
#define MMIO_MARKER  0xB16B00B5     /* To quickly decide if address == MMIO */

/**
 * MMIO Handler table
 * Handles an MMIO trap depending on its mapping.
 *
 * @param address gives the handler the "original" address
 * @param size    byte/word/etc?
 * @param value   The value to be written, if this is a write call
 */
typedef u32 (*mmioHandler)( u32 address, u8 size, u32 value );
static mmioHandler mmioReadHandlers[ 0x400 ];
static mmioHandler mmioWriteHandlers[ 0x400 ];

/**
 * initializeMMIO
 * Sets up the MMIO handler table
 */
void initializeMMIO();

/**
 * invalidMMIOCall
 * Error report for invalid indexing into the handler table
 */
u32 invalidMMIOCall( u32 address, u8 size, u32 value );

#endif /* __MMIO_H__ */
